<?php
class Application_Main_Logic_Index extends Library_Core_Logic
{
	public function index()
	{
		//throw new Library_Exception("This is an uncaught Exception!", 4);
		/*
		$adapter = new Library_Database_Adapter_MySql();
		$adapter->connect("mysql1083.servage.net", "SaroSoftware", "a9sna1na113", "SaroSoftware");
		$downloads = new Application_Tables_Downloads();
		$downloads->setAdapter($adapter);
				
		$rowset = $downloads->findAll(array(
				array("product", "WhiteBoard - 0.1.zip", $adapter->EQUALS),
				array("timestamp", "1269866394", $adapter->LESSTHANEQUALS)
		));
		
		// $rowset is an object of Library_Database_RowSet
		// NEW WAY:
		
		*/
		
		$db = $this->registry->db;
		
		$rowset = $db->downloads->all
		(
			array('product' => "WhiteBoard - 0.1.zip",
			 		'timestamp <' => "1269866394")
		);
//		
//		findAll(array(
//				array("product", "WhiteBoard - 0.1.zip", $db->adapter->operators["EQUALS"]),
//				array("timestamp", "1269866394", $db->adapter->operators["LESSTHANEQUALS"])
//			));
		
		

		foreach($rowset as $row)
		{
			foreach($row->toArray() as $key=>$value)
			{
				echo "Key: ".$key.", Value: ".$value."<br />";
			}
			echo "<br /><br />";
		}
				
		$this->view->Version = Library_Version::getVersion();
		
		
	}
	
	public function form()
	{
		$form = new Application_Main_Forms_Test();
		
		// If the form was posted
		if($_SERVER['REQUEST_METHOD'] == "POST" && $form->validate())
		{
			// The form is valid, do actions!
			echo "the form is valid";
		}
		
		$this->view->form = $form;
	}
}
?>